<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">User Details</f:facet>


        <s:decorate id="dsc" template="layout/display.xhtml">
            <ui:define name="label">Dsc</ui:define>
            <h:outputText value="#{userHome.instance.dsc}"/>
        </s:decorate>

        <s:decorate id="email" template="layout/display.xhtml">
            <ui:define name="label">Email</ui:define>
            <h:outputText value="#{userHome.instance.email}"/>
        </s:decorate>

        <s:decorate id="firstname" template="layout/display.xhtml">
            <ui:define name="label">Firstname</ui:define>
            <h:outputText value="#{userHome.instance.firstname}"/>
        </s:decorate>

        <s:decorate id="lastloggedin" template="layout/display.xhtml">
            <ui:define name="label">Lastloggedin</ui:define>
            <h:outputText value="#{userHome.instance.lastloggedin}">
                <s:convertDateTime type="both" dateStyle="short"/>
            </h:outputText>
        </s:decorate>

        <s:decorate id="lastname" template="layout/display.xhtml">
            <ui:define name="label">Lastname</ui:define>
            <h:outputText value="#{userHome.instance.lastname}"/>
        </s:decorate>

        <s:decorate id="password" template="layout/display.xhtml">
            <ui:define name="label">Password</ui:define>
            <h:outputText value="#{userHome.instance.password}"/>
        </s:decorate>

        <s:decorate id="registered" template="layout/display.xhtml">
            <ui:define name="label">Registered</ui:define>
            <h:outputText value="#{userHome.instance.registered}">
                <s:convertDateTime type="both" dateStyle="short"/>
            </h:outputText>
        </s:decorate>

        <s:decorate id="username" template="layout/display.xhtml">
            <ui:define name="label">Username</ui:define>
            <h:outputText value="#{userHome.instance.username}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/UserEdit.xhtml"
                    id="edit"
                 value="Edit"/>

        <s:button view="/#{empty userFrom ? 'UserList' : userFrom}.xhtml"
                    id="done"
                 value="Done"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Friendships applied to me</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="friendshipsAppliedToMeChildren">

        <h:outputText value="There are no friendshipsAppliedToMe associated with this user."
                   rendered="#{empty userHome.friendshipsAppliedToMe}"/>

        <rich:dataTable value="#{userHome.friendshipsAppliedToMe}"
                       var="_friendship"
                  rendered="#{not empty userHome.friendshipsAppliedToMe}"
                rowClasses="rvgRowOne,rvgRowTwo"
                        id="friendshipsAppliedToMeTable">
            <rich:column sortBy="#{_friendship.id.user1}">
                <f:facet name="header">User1</f:facet>
                <h:outputText value="#{_friendship.id.user1}"/>
            </rich:column>
            <rich:column sortBy="#{_friendship.id.user2}">
                <f:facet name="header">User2</f:facet>
                <h:outputText value="#{_friendship.id.user2}"/>
            </rich:column>
            <rich:column sortBy="#{_friendship.confirmed}">
                <f:facet name="header">Confirmed</f:facet>
                <h:outputText value="#{_friendship.confirmed}"/>
            </rich:column>
            <h:column>
                <f:facet name="header">Action</f:facet>
                <s:link id="selectfriendship"
                     value="Select"
                      view="/Friendship.xhtml">
                    <f:param name="friendshipUser1"
                            value="#{_friendship.id.user1}"/>
                    <f:param name="friendshipUser2"
                            value="#{_friendship.id.user2}"/>
                    <f:param name="friendshipFrom" value="User"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Add friendship"
                view="/FriendshipEdit.xhtml">
            <f:param name="userId"
                    value="#{userHome.instance.id}"/>
            <f:param name="friendshipFrom" value="User"/>
        </s:button>
    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Friendships i applied</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="friendshipsIAppliedChildren">

        <h:outputText value="There are no friendshipsIApplied associated with this user."
                   rendered="#{empty userHome.friendshipsIApplied}"/>

        <rich:dataTable value="#{userHome.friendshipsIApplied}"
                       var="_friendship"
                  rendered="#{not empty userHome.friendshipsIApplied}"
                rowClasses="rvgRowOne,rvgRowTwo"
                        id="friendshipsIAppliedTable">
            <rich:column sortBy="#{_friendship.id.user1}">
                <f:facet name="header">User1</f:facet>
                <h:outputText value="#{_friendship.id.user1}"/>
            </rich:column>
            <rich:column sortBy="#{_friendship.id.user2}">
                <f:facet name="header">User2</f:facet>
                <h:outputText value="#{_friendship.id.user2}"/>
            </rich:column>
            <rich:column sortBy="#{_friendship.confirmed}">
                <f:facet name="header">Confirmed</f:facet>
                <h:outputText value="#{_friendship.confirmed}"/>
            </rich:column>
            <h:column>
                <f:facet name="header">Action</f:facet>
                <s:link id="selectfriendship"
                     value="Select"
                      view="/Friendship.xhtml">
                    <f:param name="friendshipUser1"
                            value="#{_friendship.id.user1}"/>
                    <f:param name="friendshipUser2"
                            value="#{_friendship.id.user2}"/>
                    <f:param name="friendshipFrom" value="User"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Add friendship"
                view="/FriendshipEdit.xhtml">
            <f:param name="userId"
                    value="#{userHome.instance.id}"/>
            <f:param name="friendshipFrom" value="User"/>
        </s:button>
    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Role</h:panelGroup>
        </f:facet>
    <div class="association" id="roleParent">

        <h:outputText value="There is no role associated with this user."
                   rendered="#{userHome.instance.role == null}"/>

        <rich:dataTable var="_role"
                   value="#{userHome.instance.role}"
                rendered="#{userHome.instance.role != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="roleTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_role.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Description</f:facet>
                <h:outputText value="#{_role.description}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Title</f:facet>
                <h:outputText value="#{_role.title}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewrole"
                     value="View"
                      view="/Role.xhtml">
                    <f:param name="roleId"
                           value="#{_role.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Status</h:panelGroup>
        </f:facet>
    <div class="association" id="statusParent">

        <h:outputText value="There is no status associated with this user."
                   rendered="#{userHome.instance.status == null}"/>

        <rich:dataTable var="_status"
                   value="#{userHome.instance.status}"
                rendered="#{userHome.instance.status != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="statusTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_status.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Dsc</f:facet>
                <h:outputText value="#{_status.dsc}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status</f:facet>
                <h:outputText value="#{_status.status}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewstatus"
                     value="View"
                      view="/Status.xhtml">
                    <f:param name="statusId"
                           value="#{_status.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
